Ext.require([
		'Ext.grid.*',
		'Ext.toolbar.Paging', 
		'Ext.data.*' 
]);
Ext.onReady(function() {
	Ext.define('MyData',{
		extend:'Ext.data.Model',
		fields:[{id:'id',mapping:'ID'},'NAME','AUTHOR','PRICE','PUBLISHDATE','ADDRESS','TYPE_NAME']
	});
	
	var store = Ext.create('Ext.data.Store',{
		pageSize:10,
		model:'MyData',
		remoteSort:true,
		proxy:{
			type:'ajax',
			url:'queryBookList',
			reader:{
				root:'list',
				totalProperty  : 'total'
			},
			simpleStoreModel:true
		},
		sorters:[
		{
			property:'publishdate',
			direction:'desc'
		}
		]
	});
	
	var grid = Ext.create('Ext.grid.Panel',{
		store:store,
		columns:[
		{text:'作者',width:120,dataIndex:'AUTHOR',sortable:true},
		{text:'书名',width:120,dataIndex:'NAME',sortable:true},
		{text:'价格',width:120,dataIndex:'PRICE',sortable:true},
		{text:'出版日期',width:120,dataIndex:'PUBLISHDATE',sortable:true},
		{text:'出版地址',width:120,dataIndex:'ADDRESS',sortable:true},
		{text:'类型',width:120,dataIndex:'TYPE_NAME',sortable:true}
		],
		height:400,
		width:720,
		title:'grid分页',
		disableSelection:true,
		loadMask:true,
		renderTo:'demo',
		viewConfig:{
			id: 'gv', 
			trackOver: false, 
			stripeRows: false

		},
		bbar:Ext.create('Ext.PagingToolbar',{
			store: store, 
	        displayInfo: true, 
	        displayMsg: '显示 {0} - {1} 条，共计 {2} 条', 
	        emptyMsg: "没有数据"

		})
	});
	store.loadPage(1); 
})
